<?php

class Density extends DirModel
{

	public $viewColumns=array('ut_density_value');
	
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'ut_density';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ut_density_value', 'required'),
			array('ut_density_value', 'type', 'type'=>'float'),
		);
	}

	public function scopes()
	{
		return array(
			'paperKind'=>array(
				'condition'=>'EXISTS (SELECT * FROM ut_paper up WHERE up.ut_density_id=t.ut_density_id AND up.ut_paper_kind_id=:paperKind OR :paperKind IS NULL)',
			),
		);
	}	
	
	
	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'paper'=>array(self::BELONGS_TO,'Paper','ut_paper_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'Id',
			'ut_density_value' => 'Плотность',
		);
	}

}